package org.gr.ias.common.realm;


import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.gr.ias.common.entity.SysRoleAuthorityKey;
import org.gr.ias.common.entity.SysUser;
import org.gr.ias.jurisdiction.mapper.SysRoleAuthorityMapper;
import org.gr.ias.user.mapper.SysUserMapper;
import tk.mybatis.mapper.entity.Example;
import org.gr.ias.jurisdiction.mapper.SysRoleAuthorityMapper;

import javax.annotation.Resource;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 自定义Realm
 * @author zhaoming.li
 *
 */
@Slf4j
public class MyRealm extends AuthorizingRealm{

	/**
	 * 授权
	 */
	@Override
	protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
		String userName=(String) SecurityUtils.getSubject().getPrincipal();
		log.info("授权管理获取用户名:"+userName);
		return null;
	}
	/**
	 * 权限认证
	 */
	@Override
	protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
		String userName=(String)token.getPrincipal();
		log.info("权限认证获取用户名:"+userName);
		return null;
	}
}
